feat: Local database mode with PostgreSQL + PostgREST (no Supabase cloud required)#948
Closed
LEEI1337 wants to merge 2 commits intocoleam00:stablefrom
Closed
feat: Local database mode with PostgreSQL + PostgREST (no Supabase cloud required)#948LEEI1337 wants to merge 2 commits intocoleam00:stablefrom
LEEI1337 wants to merge 2 commits intocoleam00:stablefrom
Conversation
Add LOCAL_DB=true option to run Archon entirely locally without Supabase cloud dependency. All data stays on the user's machine. Changes: - docker-compose.yml: Add archon-db (pgvector/pgvector:pg16), archon-postgrest, and archon-postgrest-proxy (nginx) services - local-db/: New directory with nginx.conf (Supabase URL compatibility layer) and complete_setup_local.sql (RLS policies adapted for PostgREST without Supabase Auth) - .env.example: Add LOCAL_DB toggle and local database configuration - config.py: Skip JWT validation in local mode, auto-configure URLs - client_manager.py: Auto-configure Supabase client for local PostgREST - credential_service.py: Same local database support - Makefile: Add dev-local-db, local-db-up/down/reset/logs commands - README.md: Document local database mode with architecture diagrams Architecture: PostgreSQL 16 + pgvector → PostgREST → Nginx proxy (/rest/v1/ → /) for full supabase-py compatibility without code changes.
- Remove head=True from all count queries to fix postgrest-py bug where Content-Range headers with '*' caused int() crash - Fix validate_supabase_url to allow Docker service names in local mode - Fix internal port references for PostgREST proxy - Add JWT secret for PostgREST authentication - Fix missing return statement in _get_encryption_key
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LOCAL_DB=trueoption to run Archon entirely locally with no Supabase cloud dependency — all data stays on the user's machinesupabase-pyclient works identically in both modesArchitecture
The Nginx proxy maps
/rest/v1/paths to PostgREST's root paths, making it fully compatible with thesupabase-pyclient.What's Changed
New files
local-db/nginx.conf— Nginx proxy for Supabase URL compatibilitylocal-db/complete_setup_local.sql— Complete DB schema with RLS policies adapted for PostgREST (noauth.role())Modified files
docker-compose.yml— Addarchon-db,archon-postgrest,archon-postgrest-proxyservices (profile:local-db).env.example— AddLOCAL_DBtoggle and local database configurationpython/src/server/config/config.py— Skip JWT validation in local mode, auto-configure URLspython/src/server/services/client_manager.py— Local database URL handlingpython/src/server/services/credential_service.py— Local database URL handlingMakefile— Adddev-local-db,local-db-up/down/reset/logscommandsREADME.md— Document local database mode with architecture diagramsUsage
No Supabase account needed. No manual SQL execution. Everything starts automatically.
Why This Approach
There have been several attempts at database abstraction (#918, #915, #375) involving heavy Python refactoring. This approach avoids all that by using PostgREST as a drop-in replacement for the Supabase REST API, keeping the existing
supabase-pyclient calls 100% intact.